import java.util.Scanner;

public class Test10 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt(), q = scanner.nextInt();
        int[] arr = new int[n + 1];
        for(int i = 1 ; i <= n ; i++) arr[i] = scanner.nextInt();
        long[] dp = new long[n + 1];
        for(int i = 1; i <= n; i++) dp[i] = dp[i - 1] + arr[i];
        while(q > 0){
            int left = scanner.nextInt(); int right = scanner.nextInt();
            System.out.println(dp[right] - dp[left - 1]);
            q--;
        }
    }
}
